﻿@{
    Layout = "~/Views/Shared/_FormWhite.cshtml";
}
<style type="text/css">
    img {
        max-height: 100px;
        max-width: 100px;
    }
</style>
<div class="wrapper animated fadeInRight">
    <form id="form" class="form-horizontal m">
        <div class="form-group">
            <label class="col-sm-2 control-label ">所有人姓名：<font class="red"> *</font></label>
            <div class="col-sm-4">
                <input id="ownerName" col="OwnerName" type="text" class="form-control" />
            </div>
            <label class="col-sm-2 control-label ">地址：<font class="red"> *</font></label>
            <div class="col-sm-4">
                <input id="ownerAddr" col="OwnerAddr" type="text" class="form-control" />
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label ">身份证号：<font class="red"> *</font></label>
            <div class="col-sm-4">
                <input id="ownerCardNo" col="OwnerCardNo" type="text" class="form-control" />
            </div>
            <label class="col-sm-2 control-label ">电话：<font class="red"> *</font></label>
            <div class="col-sm-4">
                <input id="ownerTel" col="OwnerTel" type="text" class="form-control" />
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label ">登记类型：<font class="red"> *</font></label>
            <div class="col-sm-4">
                <div id="jXDJLX" col="JXDJLX"></div>
            </div>
            <label class="col-sm-2 control-label ">机械类别：<font class="red"> *</font></label>
            <div class="col-sm-4">
                <div id="jXLB" col="JXLB"></div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label ">排放阶段：<font class="red"> *</font></label>
            <div class="col-sm-4">
                <div id="pFJD" col="PFJD"></div>
            </div>
            <label class="col-sm-2 control-label ">所属县区：<font class="red"> *</font></label>
            <div class="col-sm-4">
                <div id="Region" col="Region"></div>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-6">
                <a href="#" class="thumbnail">
                    <img src="/image/NoImg.jpg" id="img_OwnerCard_Pic">
                </a>
                <input id="ownerCard_Pic" col="OwnerCard_Pic" type="hidden" class="form-control" />
            </div>
            <div class="col-sm-6">
                <a href="#" class="thumbnail">
                    <img src="/image/NoImg.jpg" id="img_JX1_pic">
                </a>
                <input id="jX1_pic" col="JX1_pic" type="hidden" class="form-control" />
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label ">审核状态：<font class="red"> *</font></label>
            <div class="col-sm-2">
                <div id="auditStatus" col="AuditStatus"></div>
            </div>
            <label class="col-sm-2 control-label ">审核人：<font class="red"> *</font></label>
            <div class="col-sm-2">
                <input id="auditUserName" col="AuditUserName" type="text" class="form-control" readonly />
            </div>
            <label class="col-sm-2 control-label ">审核时间：<font class="red"> *</font></label>
            <div class="col-sm-2">
                <input id="auditTime" col="AuditTime" type="text" class="form-control" readonly />
            </div>
        </div>
    </form>
</div>

<script type="text/javascript">
    var id = ys.request("id");
    $(function () {
        getForm();
        $("#jXDJLX").ysComboBox({
            data: top.getDataDict("JXDJLX"),
            key: "DictKey",
            value: "DictValue",
            class: "form-control"
        });
        $("#jXLB").ysComboBox({
            data: top.getDataDict("JXLB"),
            key: "DictKey",
            value: "DictValue",
            class: "form-control"
        });

        $("#pFJD").ysComboBox({
            data: top.getDataDict("PFJD"),
            key: "DictKey",
            value: "DictValue",
            class: "form-control"
        });
        $("#Region").ysComboBox({
            data: top.getDataDict("Region"),
            key: "DictValue",
            value: "DictValue",
            class: "form-control"
        });
        $("#auditStatus").ysComboBox({
            data: top.getDataDict("AuditStatus"),
            key: "DictKey",
            value: "DictValue",
            class: "form-control",
            disabled: true
        });
        $('#form').validate({
            rules: {
                ownerName: { required: true }
            }
        });
    });

    function getForm() {
        if (id > 0) {
            ys.ajax({
                url: '@Url.Content("~/YiDongYuan/MechanicsApply/GetFormJson")' + '?id=' + id,
                type: 'get',
                success: function (obj) {
                    if (obj.Tag == 1) {
                        $('#form').setWebControls(obj.Data);
                        if (obj.Data.OwnerCard_pic) {
                            $("#img_OwnerCard_Pic").attr('src', 'https://jxhfd-api.sxxmlg.cn/File/Show?id=' + obj.Data.OwnerCard_pic)
                        }
                        if (obj.Data.JX1_pic) {
                            $("#img_JX1_pic").attr('src', 'https://jxhfd-api.sxxmlg.cn/File/Show?id=' + obj.Data.JX1_pic)
                        }
                        $("img").click(function () {
                            var src = $(this).attr('src');
                            var id = src.substr(src.indexOf('=') + 1);
                            window.open("/YiDongYuan/BaseFile/ShowImg?id=" + id);
                        });
                    }
                }
            });
        }
        else {
            var defaultData = {};
            $('#form').setWebControls(defaultData);
        }
    }

    function saveForm(index) {
        if ($('#form').validate().form()) {
            var postData = $('#form').getWebControls({ Id: id });
            ys.ajax({
                url: '@Url.Content("~/YiDongYuan/MechanicsApply/SaveFormJson")',
                type: 'post',
                data: postData,
                success: function (obj) {
                    if (obj.Tag == 1) {
                        ys.msgSuccess(obj.Message);
                        parent.searchGrid();
                        parent.layer.close(index);
                    }
                    else {
                        ys.msgError(obj.Message);
                    }
                }
            });
        }
    }
</script>

